 //0.导入组件
 import { createRouter, createWebHistory } from 'vue-router'
 //  import Home from '../views/home/Home'
 //  import Category from '../views/category/Category'
 //  import Cart from '../views/cart/Cart'
 //  import Profile from '../views/profile/Profile'
 const Detail = () =>
     import ('../views/detail/Detail')

 ///////////////////////////////////////路由懒加载
 const Home = () =>
     import ( /* webpackChunkName:"mymall1" */ '../views/home/Home')
 const Category = () =>
     import ( /* webpackChunkName:"mymall2" */ '../views/category/Category')
 const Cart = () =>
     import ( /* webpackChunkName:"mymall3" */ '../views/cart/Cart')
 const Profile = () =>
     import ( /* webpackChunkName:"mymall4" */ '../views/profile/Profile')


 //2.配置路由
 const routes = [{
         //配置默认路由
         path: '/',
         redirect: '/home'
     },
     //配置跳转路由映射
     {
         path: '/home',
         name: 'Home',
         component: Home
             // route level code-splitting
             // this generates a separate chunk (about.[hash].js) for this route
             // which is lazy-loaded when the route is visited.
             //可以在配置时导入
             // component: () =>
             //     import ( /* webpackChunkName: "about" */ '../views/About.vue')
     },
     {
         path: '/category',
         name: 'Category',
         component: Category
     },
     {
         path: '/cart',
         name: 'Cart',
         component: Cart
     },
     {
         path: '/profile',
         name: 'Profile',
         component: Profile
     },
     {
         //路由传参有两种方式：id/对象path+query
         path: '/detail/:iid',
         name: 'Detail',
         component: Detail
     },
 ]

 //1.创建路由对象
 const router = createRouter({
     history: createWebHistory(process.env.BASE_URL),
     routes
 })

 //3.导出路由对象
 export default router